layui.config({  // common.js是配置layui扩展模块的目录，每个页面都需要引入
    version: '1.0',   // 更新组件缓存，设为true不缓存，也可以设一个固定值
    base: getProjectUrl() + 'assets/module/'
}).extend({
    steps: 'steps/steps',
    notice: 'notice/notice',
    cascader: 'cascader/cascader',
    //dropdown: 'dropdown/dropdown',
    fileChoose: 'fileChoose/fileChoose',
    Split: 'Split/Split',
    Cropper: 'Cropper/Cropper',
    tagsInput: 'tagsInput/tagsInput',
    citypicker: 'city-picker/city-picker',
    introJs: 'introJs/introJs',
    zTree: 'zTree/zTree'
}).use(['layer', 'admin'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var admin = layui.admin;
    /**
     * @param e 查看图片对象
     */
    window.showBigImage=function (e) {
        parent.layer.open({
            type: 1,
            title: false,
            closeBtn: 1,
            shadeClose: true, //点击阴影关闭
            area: "[$(e).width + 'px', $(e).height + 'px']", //宽高
            content: "<img src=" + $(e).attr('src') + " />"
        });
    }
    // 移除loading动画
    /*setTimeout(function () {
        admin.removeLoading();
    }, window === top ? 300 : 0);*/
});

/** 获取当前项目的根路径，通过获取layui.js全路径截取assets之前的地址 */
function getProjectUrl() {
    var layuiDir = layui.cache.dir;
    if (!layuiDir) {
        var js = document.scripts, last = js.length - 1, src;
        for (var i = last; i > 0; i--) {
            if (js[i].readyState === 'interactive') {
                src = js[i].src;
                break;
            }
        }
        var jsPath = src || js[last].src;
        layuiDir = jsPath.substring(0, jsPath.lastIndexOf('/') + 1);
    }
    return layuiDir.substring(0, layuiDir.indexOf('assets'));
}
/** 金额输入限制 */
window.input_amout=function (obj){
    //如果输入非数字，则替换为''
    obj.value = obj.value.replace(/[^\d\.]/g, '');
    //必须保证第一个为数字而不是.     
    obj.value = obj.value.replace(/^\./g,'');
    //保证只有出现一个.而没有多个.     
    obj.value = obj.value.replace(/\.{2,}/g,'.');
    //保证.只出现一次，而不能出现两次以上     
    obj.value = obj.value.replace('.','$#$').replace(/\./g,'').replace('$#$','.');
    //只能输入两位小数
    obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');
}
//查看视频
window.read_video=function (video){
    var loadstr = '<video width="100%" height="100%" controls="controls" autobuffer="autobuffer" autoplay="autoplay" loop="loop"><source src="' + video + '" type="video/mp4"></source></video>'
    parent.layer.open({
        type: 1,
        title: '播放视频',
        area:"100%",
        content: loadstr,
    });
}


